home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / edit / VE-shadow.lha / arexx / Shadow.rexx
OS/2 REXX Batch file  |  1998-12-31  |  10KB  |  599 lines

  1. /*
  2.  
  3.    v2.94 Shadow
  4.  
  5.    Marko Seppänen
  6.    marko.seppanen@wwnet.fi
  7.  
  8. */
  9.  
  10.  
  11. address IMAGEENGINEER
  12.  
  13. Options results
  14. signal on error            /* Setup a place for errors to go */
  15.  
  16.  
  17. if arg()=0 then exit
  18. x=arg(1)
  19. x0=subword(x,1,1)
  20. shadow=subword(x,2,1)
  21. lowp=subword(x,3,1)
  22. xplace=subword(x,4,1)
  23. yplace=subword(x,5,1)
  24. space=subword(x,6,1)
  25.  
  26.  
  27. MARK x0 PRIMARY
  28. PROJECT_INFO x0 WIDTH
  29. picwidth=result
  30. PROJECT_INFO x0 HEIGHT
  31. picheight=result
  32. PROJECT_INFO x0 ZOOM
  33. origzoomvalue=result
  34.  
  35.  
  36.  
  37. if shadow="" then do
  38.  
  39.   if exists("ie:prefs/veshadow.cfg") == "1" then
  40.     do
  41.       call open("temp","ie:prefs/veshadow.cfg","R")
  42.       values=readln("temp")
  43.       parse var values ok shadow lowp xplace yplace space .
  44.       call close("temp")
  45.     end
  46.   else
  47.     do
  48.       shadow=0
  49.       lowp=9
  50.       xplace="-5"
  51.       yplace="-5"
  52.       space=0
  53.     end
  54.  
  55.  
  56.   'FORM "Shadow" "Use|Cancel"',
  57.   'CYCLE,"Type of shadow","Transparent|Lowpass|Normal|Regtangle|Color|Smooth",'shadow'',
  58.   'INTEGER,"Lowpass value",1,25,'lowp',SLIDER',
  59.   'INTEGER,"X-place",-20,20,'xplace',SLIDER',
  60.   'INTEGER,"Y-place",-20,20,'yplace',SLIDER',
  61.   'INTEGER,"Space around",0,100,'space',SLIDER'
  62.  
  63.   values=result
  64.   parse var values ok shadow lowp xplace yplace space .
  65.  
  66.   if ok = 0 then exit
  67.  
  68.   call open("temp","ie:prefs/veshadow.cfg","W")
  69.   res=writeln("temp",values)
  70.   call close("temp")
  71.  
  72. end
  73.  
  74.  
  75.  
  76. /* DO WE NEED SOME SPACE AROUND? */
  77.  
  78.  
  79. if space>0 then do
  80.   if exists("ie:arexx/addspace.rexx") == "0" then do
  81.     'REQUEST "AddSpace.rexx is missing!" "I will get it... sorry"'
  82.     exit
  83.   end
  84.   address command "rexx:rx ie:arexx/AddSpace.rexx" x0 space WHITE
  85.  
  86.   PROJECT_LIST
  87.   xyz=result
  88.   xpic=subword(xyz,1,1)
  89. end
  90. else xpic=x0
  91.  
  92.  
  93.  
  94. /* THE SHADOW HIMSELF */
  95.  
  96. select
  97.  
  98.   when shadow == 0 then do
  99.  
  100.     LOWPASS xpic lowp lowp
  101.     gblur=result
  102.  
  103.     if space~=0 then CLOSE xpic
  104.  
  105. /*
  106.  
  107.     CONVOLVE xpic "IE:Convolves/GaussianBlur5x5"
  108.     x1=result
  109.  
  110.  
  111.     CONVOLVE x1 "IE:Convolves/GaussianBlur5x5"
  112.     x2=result
  113.  
  114.     CLOSE x1
  115.  
  116.     CONVOLVE x2 "IE:Convolves/GaussianBlur5x5"
  117.     gblur=result
  118.  
  119.     CLOSE x2
  120.  
  121. */
  122.  
  123.     MARK x0 PRIMARY
  124.     MARK x0 ALPHA
  125.     MARK gblur SECONDARY
  126.  
  127.     COMPOSITE xplace+space yplace+space MIN
  128.  
  129.     CLOSE gblur
  130.  
  131.   end
  132.  
  133.  
  134.   when shadow == 1 then do
  135.  
  136.     LOWPASS xpic lowp lowp
  137.     gblur=result
  138.  
  139.     if space~=0 then CLOSE xpic
  140.  
  141.     THRESHOLD x0 255
  142.     pic=result
  143.  
  144.     NEGATIVE pic
  145.     pic2=result
  146.  
  147.     CLOSE pic
  148.  
  149.  
  150.     MARK pic2 PRIMARY
  151.     MARK pic2 ALPHA
  152.     MARK gblur SECONDARY
  153.  
  154.     COMPOSITE xplace+space yplace+space MAX
  155.     x4=result
  156.  
  157.     CLOSE pic2
  158.     CLOSE gblur
  159.  
  160.     MARK x0 PRIMARY
  161.     MARK x0 ALPHA
  162.     MARK x4 SECONDARY
  163.  
  164.     COMPOSITE xplace+space yplace+space MIN
  165.  
  166.     CLOSE x4
  167.  
  168.   end
  169.  
  170.  
  171.  
  172.   when shadow == 2 then do
  173.  
  174.     do
  175.       if exists("ie:prefs/veshadownormal.cfg") == "1" then
  176.         do
  177.           call open("temp","ie:prefs/veshadownormal.cfg","R")
  178.           values=readln("temp")
  179.           parse var values ok style .
  180.           call close("temp")
  181.         end
  182.       else
  183.         do
  184.           style=0
  185.         end
  186.  
  187.  
  188.       'FORM "Shadow - normal" "Use|Cancel"',
  189.       'CYCLE,"Style of shadow","Normal|Vertical lines|Horizontal lines|Crossed lines|Slash lines 1|Slash lines 2|Diamond lines",'style'',
  190.  
  191.       values=result
  192.       parse var values ok style .
  193.  
  194.       if ok = 0 then exit
  195.  
  196.       call open("temp","ie:prefs/veshadownormal.cfg","W")
  197.       res=writeln("temp",values)
  198.       call close("temp")
  199.  
  200.     end
  201.  
  202.  
  203.     if style=="1" then linetype="vertical"
  204.     if style=="2" then linetype="horizontal"
  205.     if style=="3" then linetype="crossed"
  206.     if style=="4" then linetype="slash1"
  207.     if style=="5" then linetype="slash2"
  208.     if style=="6" then linetype="diamond"
  209.  
  210.  
  211.     if style~="0" then do
  212.       if exists("ie:alpha/Visual-lines"linetype".alpha") == "0" then do
  213.         'REQUEST "Please download VE-!Extras.lha" "Ok"'
  214.         exit
  215.       end
  216.     end
  217.  
  218.     THRESHOLD xpic 255
  219.     pic=result
  220.  
  221.     NEGATIVE pic
  222.     pic2=result
  223.  
  224.     if style~="0" then do
  225.  
  226.       OPEN "ie:alpha/Visual-lines"linetype".alpha" COLOUR
  227.       lines=result
  228.  
  229.       RESIZE lines picwidth+space picheight+space TILE
  230.       lines2=result
  231.  
  232.       CLOSE lines
  233.       PROJECT_SET lines2 ZOOM origzoomvalue
  234.  
  235.       MARK lines2 PRIMARY
  236.       MARK lines2 ALPHA
  237.       MARK pic SECONDARY
  238.  
  239.       COMPOSITE 0 0 MAX
  240.       shadowpic=result
  241.  
  242.       CLOSE lines2
  243.       CLOSE pic
  244.  
  245.     end
  246.     else shadowpic=pic
  247.  
  248.  
  249.     LOWPASS shadowpic lowp lowp
  250.     lowpasspic=result
  251.  
  252.     CLOSE shadowpic
  253.  
  254.     CONTRAST_STRETCH lowpasspic
  255.     gshadow=result
  256.  
  257.     CLOSE lowpasspic
  258.  
  259.  
  260.     MARK pic2 PRIMARY
  261.     MARK pic2 ALPHA
  262.     MARK gshadow SECONDARY
  263.  
  264.     COMPOSITE xplace yplace MAX
  265.     x3=result
  266.  
  267.     CLOSE pic2
  268.  
  269.     CLOSE gshadow
  270.  
  271.     MARK xpic PRIMARY
  272.     MARK xpic ALPHA
  273.     MARK x3 SECONDARY
  274.  
  275.     COMPOSITE xplace yplace MIN
  276.  
  277.     CLOSE x3
  278.     if space~=0 then CLOSE xpic
  279.  
  280.   end
  281.  
  282.  
  283.   when shadow == 3 then do
  284.  
  285.     AUTOCROP xpic
  286.     pic2=result
  287.  
  288.     PROJECT_INFO pic2 WIDTH
  289.     newpicwidth=result
  290.     PROJECT_INFO pic2 HEIGHT
  291.     newpicheight=result
  292.  
  293.  
  294.     BRIGHTNESS pic2 "-255"
  295.     black=result
  296.  
  297.  
  298.     if exists("ie:alpha/Visual-roundcorner.alpha") == "0" then do
  299.       'REQUEST "Please download VE-!Extras.lha" "Ok"'
  300.       exit
  301.     end
  302.  
  303.     OPEN "ie:alpha/Visual-roundcorner.alpha" COLOUR
  304.     cornerA=result
  305.  
  306.     MARK cornerA PRIMARY
  307.     MARK cornerA ALPHA
  308.     MARK black SECONDARY
  309.     COMPOSITE 0 0 ADD
  310.     corner1=result
  311.  
  312.     CLOSE black
  313.  
  314.     REFLECT_X cornerA
  315.     cornerB=result
  316.     CLOSE cornerA
  317.  
  318.     MARK cornerB PRIMARY
  319.     MARK cornerB ALPHA
  320.     MARK corner1 SECONDARY
  321.     COMPOSITE newpicwidth-3 0 ADD
  322.     corner2=result
  323.  
  324.     CLOSE corner1
  325.  
  326.     REFLECT_Y cornerB
  327.     cornerC=result
  328.     CLOSE cornerB
  329.  
  330.     MARK cornerC PRIMARY
  331.     MARK cornerC ALPHA
  332.     MARK corner2 SECONDARY
  333.     COMPOSITE newpicwidth-3 newpicheight-3 ADD
  334.     corner3=result
  335.  
  336.     CLOSE corner2
  337.  
  338.     REFLECT_X cornerC
  339.     cornerD=result
  340.     CLOSE cornerC
  341.  
  342.     MARK cornerD PRIMARY
  343.     MARK cornerD ALPHA
  344.     MARK corner3 SECONDARY
  345.     COMPOSITE 0 newpicheight-3 ADD
  346.     roundbox=result
  347.  
  348.     CLOSE corner3
  349.     CLOSE cornerD
  350.  
  351.  
  352.  
  353.     /* SOME WORKSPACE AROUND */
  354.  
  355.  
  356.     if exists("ie:arexx/addspace.rexx") == "0" then do
  357.       'REQUEST "AddSpace.rexx is missing!" "I will get it... sorry"'
  358.       exit
  359.     end
  360.     address command "rexx:rx ie:arexx/AddSpace.rexx" roundbox 20 WHITE
  361.  
  362.     PROJECT_LIST
  363.     xyz=result
  364.     shadowpic=subword(xyz,1,1)
  365.  
  366.     CLOSE roundbox
  367.  
  368.  
  369.  
  370.     /* READY TO CONTINUE */
  371.  
  372.  
  373.     LOWPASS shadowpic lowp lowp
  374.     gshadow=result
  375.  
  376.  
  377.  
  378.     CLOSE shadowpic
  379.  
  380.     BRIGHTNESS pic2 255
  381.     bright=result
  382.  
  383.     MARK bright PRIMARY
  384.     MARK bright ALPHA
  385.     MARK gshadow SECONDARY
  386.  
  387.  
  388.     COMPOSITE xplace+20 yplace+20 MAX
  389.     whitearea=result
  390.  
  391.     CLOSE gshadow
  392.     CLOSE bright
  393.  
  394.     MARK pic2 PRIMARY
  395.     MARK pic2 ALPHA
  396.     MARK whitearea SECONDARY
  397.  
  398.     COMPOSITE xplace+20 yplace+20 MIN
  399.     final=result
  400.  
  401.     CLOSE whitearea
  402.     if space~=0 then CLOSE xpic
  403.  
  404.     CLOSE pic2
  405.  
  406.   end
  407.  
  408.  
  409.   when shadow == 4 then do
  410.  
  411.     THRESHOLD xpic 255
  412.     pic=result
  413.  
  414.     CONVOLVE pic "IE:Convolves/Smooth_Ultra"
  415.     smooth1=result
  416.  
  417.     LOWPASS smooth1 lowp lowp
  418.     lowp=result
  419.  
  420.     CLOSE smooth1
  421.  
  422.     if exists("ie:arexx/primarycolors.rexx") == "0" then do
  423.       'REQUEST "PrimaryColors.rexx is missing!" "I forgot.. sorry."'
  424.       exit
  425.     end
  426.     address command "rexx:rx ie:arexx/PrimaryColors.rexx" lowp 1
  427.  
  428.     PROJECT_LIST
  429.     xyz=result
  430.     colorglow=subword(xyz,1,1)
  431.  
  432.     CLOSE lowp
  433.  
  434.  
  435.     NEGATIVE pic
  436.     neg=result
  437.  
  438.     CLOSE pic
  439.  
  440.     MARK neg PRIMARY
  441.     MARK neg ALPHA
  442.     MARK colorglow SECONDARY
  443.  
  444.     COMPOSITE xplace yplace MAX
  445.     shapecut=result
  446.  
  447.     CLOSE neg
  448.     CLOSE colorglow
  449.  
  450.     MARK xpic ALPHA
  451.     MARK xpic PRIMARY
  452.     MARK shapecut SECONDARY
  453.     COMPOSITE xplace yplace MIN
  454.     final=result
  455.  
  456.     CLOSE shapecut
  457.     if space~=0 then CLOSE xpic
  458.  
  459.  
  460.   end
  461.  
  462.  
  463.   when shadow == 5 then do
  464.  
  465.     do
  466.       if exists("ie:prefs/veshadowsmooth.cfg") == "1" then
  467.         do
  468.           call open("temp","ie:prefs/veshadowsmooth.cfg","R")
  469.           values=readln("temp")
  470.           parse var values ok outline .
  471.           call close("temp")
  472.         end
  473.       else
  474.         do
  475.           outline=0
  476.         end
  477.  
  478.  
  479.       'FORM "Shadow" "Use|Cancel"',
  480.       'CYCLE,"Outline","Yes|Exists|No",'outline'',
  481.  
  482.       values=result
  483.       parse var values ok outline .
  484.  
  485.       if ok = 0 then exit
  486.  
  487.       call open("temp","ie:prefs/veshadowsmooth.cfg","W")
  488.       res=writeln("temp",values)
  489.       call close("temp")
  490.  
  491.     end
  492.  
  493.     THRESHOLD xpic 255
  494.     thres=result
  495.  
  496.     if exists("ie:Convolves/StripEdge") == "0" then do
  497.       'REQUEST "Please download VE-!Extras.lha" "Ok"'
  498.       exit
  499.     end
  500.  
  501.     CONVOLVE thres "IE:Convolves/StripEdge"
  502.     shrink=result
  503.     CLOSE thres
  504.  
  505.     if outline>0 then do
  506.  
  507.       CONVOLVE shrink "IE:Convolves/StripEdge"
  508.       shrink2=result
  509.       CLOSE shrink
  510.       shrink=shrink2
  511.  
  512.     end
  513.  
  514.     if outline>1 then do
  515.  
  516.       CONVOLVE shrink "IE:Convolves/StripEdge"
  517.       shrink2=result
  518.       CLOSE shrink
  519.       shrink=shrink2
  520.  
  521.     end
  522.  
  523.     NEGATIVE shrink
  524.     neg=result
  525.  
  526.     CLOSE shrink
  527.  
  528.     MARK neg PRIMARY
  529.     MARK neg ALPHA
  530.     MARK xpic SECONDARY
  531.  
  532.     COMPOSITE xplace yplace MAX
  533.     slice=result
  534.  
  535.     THRESHOLD slice 255
  536.     tslice=result
  537.  
  538.     CLOSE slice
  539.  
  540.     CONVOLVE tslice "IE:Convolves/GaussianBlur5x5"
  541.     gslice=result
  542.  
  543.     CLOSE tslice
  544.  
  545.     LOWPASS gslice lowp lowp
  546.     lowpasspic=result
  547.  
  548.     CLOSE gslice
  549.  
  550.     MARK lowpasspic SECONDARY
  551.     COMPOSITE xplace yplace MAX
  552.     lslice=result
  553.  
  554.     CLOSE neg
  555.     CLOSE lowpasspic
  556.  
  557.     CONVOLVE lslice "IE:Convolves/GaussianBlur5x5"
  558.     gslice=result
  559.  
  560.     CLOSE lslice
  561.  
  562.     MARK xpic PRIMARY
  563.     MARK xpic ALPHA
  564.     MARK gslice SECONDARY
  565.  
  566.     COMPOSITE xplace yplace MIN
  567.     final=result
  568.  
  569.     CLOSE gslice
  570.  
  571.   end
  572.  
  573.  
  574. otherwise
  575.   exit
  576. end
  577.  
  578. exit
  579.  
  580.  
  581.  
  582. /*******************************************************************/
  583. /* This is where control goes when an error code is returned by IE */
  584. /* It puts up a message saying what happened and on which line     */
  585. /*******************************************************************/
  586. error:
  587. if RC=5 then do            /* Did the user just cancel us? */
  588.     IE_TO_FRONT
  589.     LAST_ERROR
  590.     'REQUEST "'||RESULT||'"'
  591.     exit
  592. end
  593. else do
  594.     IE_TO_FRONT
  595.     LAST_ERROR
  596.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  597.     exit
  598. end
  599.